;Copyright (C) 2011 Salil Bhagurkar
;
;This file is part of illusion
;
;illusion is free software: you can redistribute it and/or modify
;it under the terms of the GNU Lesser General Public License as published by
;the Free Software Foundation, either version 3 of the License, or
;(at your option) any later version.
;
;illusion is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU Lesser General Public License for more details.
;
;You should have received a copy of the GNU Lesser General Public License
;along with illusion.  If not, see <http://www.gnu.org/licenses/>.


[BITS 32]
[section .text]
bootmark db "BOO", 0



%macro pushsyscall 0
	push ebx
	push ecx
	push edx
	push esi
	push edi
%endmacro

%macro popsyscall 0
	pop edi
	pop esi
	pop edx
	pop ecx
	pop ebx
%endmacro

global __syscall
__syscall:
	push ebp
	mov ebp, esp

	pushsyscall
	mov eax, [ebp + 8]
	mov ebx, [ebp + 12]
	mov ecx, [ebp + 16]
	mov edx, [ebp + 20]
	mov esi, [ebp + 24]
	mov edi, [ebp + 28]
	int 0x80
	popsyscall

	pop ebp
	ret

global __apimod_process_return
__apimod_process_return:
	;Get the return code into first parameter
	mov ebx, eax
	mov eax, 23 ; SYS_EXITPROCESS
	int 0x80 ; This will never return

global __apimod_process_start
__apimod_process_start:
	;Get the entry address and call it
	call ecx
	;Get the return code
	mov ebx, eax
	mov eax, 23 ; SYS_EXITPROCESS
	int 0x80 ;This will never return
	jmp $

[section .data]
testd dd 0

[section .bss]
testr resd 0


